function createImg(imgName){
    let img = new egret.Bitmap();
    img.texture = RES.getRes(imgName);
    return img;
}
function createText(text:string,textAlign=egret.HorizontalAlign.LEFT,verticalAlign = egret.VerticalAlign.TOP ,size=30,textColor=0x000000){
    let myText = new egret.TextField();
    myText.text = text;
    myText.size = size;
    myText.textAlign = textAlign;
    myText.verticalAlign = verticalAlign;
    myText.textColor = textColor;
    return myText;
}
function createBtn(text,width,height,callBack=function(){},bgColor=0x999999,textColor=0xffffff,textSize=30,hoverColor=0xff0000,hoverTextColor=0xffff00){
    /***
     * Sprite和displayObjectContainer的区别
     * Sprite集成了画笔功能，即可以在sprite上直接绘制一个图形
     */
    let myBtn = new egret.Sprite();
    //myBtn.graphics.lineStyle(2,0xff0000);
    myBtn.graphics.beginFill(bgColor);
    myBtn.graphics.drawRect(0,0,width,height);
    myBtn.graphics.endFill();
    let myText = new egret.TextField();
    myText.text = text;
    myText.textColor = textColor;
    myText.size = textSize;
    myText.textAlign = "center";
    myText.verticalAlign = "middle";
    myText.width = width;
    myText.height = height;
    myBtn.addChild(myText);
    /**
     * 添加监听事件
     *  参数一：事件类型
     *  参数二：事件触发执行的函数
     *  参数三：事件函数里面的this指向
     * **/
    myBtn.touchEnabled = true;//egret里面默认所有的touch事件都是关闭的
    myBtn.addEventListener(egret.TouchEvent.TOUCH_BEGIN,function(){
        this.graphics.clear();//擦除掉画板上的图案
        this.graphics.beginFill(hoverColor);
        this.graphics.drawRect(0,0,width,height);
        this.graphics.endFill();
        myText.textColor = hoverTextColor;
    },myBtn)
    myBtn.addEventListener(egret.TouchEvent.TOUCH_END,function(){
        this.graphics.clear();//擦除掉画板上的图案
        this.graphics.beginFill(bgColor);
        this.graphics.drawRect(0,0,width,height);
        this.graphics.endFill();
        myText.textColor = textColor;
        callBack();
    },myBtn)
    myBtn.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,function(){
        this.graphics.clear();//擦除掉画板上的图案
        this.graphics.beginFill(bgColor);
        this.graphics.drawRect(0,0,width,height);
        this.graphics.endFill();
        myText.textColor = textColor;
        callBack();
    },myBtn)
    return myBtn;
}
function createRect(width,height,bgColor,lineThick=0,lineStyle=0x000000){
    let myRect = new egret.Shape();
    myRect.graphics.lineStyle(lineThick,lineStyle);
    myRect.graphics.beginFill(bgColor);
    myRect.graphics.drawRect(0,0,width,height);
    myRect.graphics.endFill();
    return myRect;
}



function timeFormat(sec){
    var totalSec = Math.floor(sec);
    var finSec = totalSec%60;
    var _finSec = finSec<10?"0"+finSec:finSec.toFixed(0);
    var finMin = Math.floor(totalSec/60);
    var _finMin = finMin<10?"0"+finMin:finMin.toFixed(0)
    return `${_finMin}:${_finSec}`;
}